import 'package:flutter/material.dart';
import 'singleChildScrollView.dart';
import 'ListViewTestRoute.dart';
import 'gridViewTestRoute.dart';
import 'scrollControllerTestRoute.dart';
import 'scrollNotificationTestRoute.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(
        title: Text("标题"),
      ),
      //body: SingleChildScrollViewTestRoute(),
      //body: ListViewTestRoute(),
      //body: ListViewTestRoute2(),
//body: InfiniteListView(),
//body: GridViewTestRoute(),
//body: GridViewTestRoute2(),
      //body: InfiniteGridView(),
      //body: CustomScrollViewTestRoute(),
//body: ScrollControllerTestRoute(),
body: ScrollNotificationTestRoute(),
    ));
  }
}

class CustomScrollViewTestRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: CustomScrollView(slivers: <Widget>[
        SliverAppBar(
            pinned: true,
            expandedHeight: 250.0,
            flexibleSpace: FlexibleSpaceBar(
                title: const Text("Demo"),
                background: Image.asset("./imgs/avatar.png"))),
        SliverPadding(
          padding: const EdgeInsets.all(8.0),
          sliver: new SliverGrid(
              gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 2, //Grid按两列显示
                  mainAxisSpacing: 10.0,
                  crossAxisSpacing: 10.0,
                  childAspectRatio: 4.0),
              delegate: new SliverChildBuilderDelegate(
                (BuildContext context, int index) {
                  return new Container(
                    alignment: Alignment.center,
                    color: Colors.cyan[100 * (index % 9)],
                    child: new Text("grid item $index"),
                  );
                },
                childCount: 20,
              )),
        ),
        //List
        new SliverFixedExtentList(
          itemExtent: 50.0,
          delegate:
              new SliverChildBuilderDelegate((BuildContext context, int index) {
            return new Container(
              alignment: Alignment.center,
              color: Colors.lightBlue[100 * (index % 9)],
              child: new Text("list item $index"),
            );
          }, childCount: 50 //50个列表项
                  ),
        )
      ]),
    );
  }
}
